嘻嘻~歡迎來到「30天前端設計之旅」的DAY 24!今天我們將探索更多有趣的文字與按鈕設計技巧,學習如何使用 CSS 實現螢光筆效果、波浪底線、錯位框線按鈕以及漸層按鈕。這些技巧將讓你能夠為網站增添更多的視覺趣味與互動性,提升整體設計質感。
D-24的學習目標:
<p class="highlighted-text">這是螢光筆底線的文字。</p>
.highlighted-text {
position: relative;
display: inline-block;
font-size: 1.5em;
}
.highlighted-text::before {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 0.3em;
background-color: #ffeb3b; /* 螢光筆顏色 */
z-index: -1;
}
<p class="wavy-underline">波浪底線效果</p>
.wavy-underline {
text-decoration: underline;
text-decoration-color: #5e9ca0;
text-decoration-style: wavy; /* 波浪線樣式 */
}
<button class="offset-border-btn">錯位框線按鈕</button>
.offset-border-btn {
position: relative;
padding: 10px 20px;
font-size: 1em;
background-color: #b8a29c;
border: 2px solid #8c8a83;
color: white;
cursor: pointer;
transition: all 0.3s ease;
}
.offset-border-btn::before {
content: '';
position: absolute;
top: -5px;
left: -5px;
width: 100%;
height: 100%;
border: 2px solid #8c8a83;
z-index: -1;
transition: all 0.3s ease;
}
.offset-border-btn:hover::before {
top: 0;
left: 0;
}
<button class="gradient-btn">漸層按鈕</button>
.gradient-btn {
padding: 10px 20px;
font-size: 1em;
color: white;
background: linear-gradient(45deg, #6b9ac4, #b8a29c);
border: none;
border-radius: 25px;
cursor: pointer;
transition: background 0.3s ease;
}
.gradient-btn:hover {
background: linear-gradient(45deg, #b8a29c, #6b9ac4);
}